package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button alphaBtn;
    private Button rotateBtn;
    private Button scaleBtn;
    private Button translateBtn;
    private ImageView animImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        alphaBtn = findViewById(R.id.alpha_btn);
        rotateBtn = findViewById(R.id.rotate_btn);
        scaleBtn = findViewById(R.id.scale_btn);
        translateBtn = findViewById(R.id.translate_btn);
        alphaBtn.setOnClickListener(this);
       rotateBtn.setOnClickListener(this);
        scaleBtn.setOnClickListener(this);
        translateBtn.setOnClickListener(this);
        animImg = findViewById(R.id.anim_img);
    }

    @Override
    public void onClick(View v) {
switch (v.getId()){
    case  R.id.alpha_btn:
//        Animation alpha = AnimationUtils.loadAnimation(this,R.anim.alpha_animation);
//        animImg.startAnimation(alpha);
        Intent intent = new Intent(MainActivity.this,TwoActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.alpha_animation,R.anim.rotate_animation);
        break;
    case  R.id.rotate_btn:
        Animation rotate = AnimationUtils.loadAnimation(this,R.anim.rotate_animation);
        animImg.startAnimation(rotate);
        break;
    case  R.id.scale_btn:
        Animation scale = AnimationUtils.loadAnimation(this,R.anim.scale_animation);
        animImg.startAnimation(scale);
        break;
    case  R.id.translate_btn:
        Animation translate = AnimationUtils.loadAnimation(this,R.anim.translate_animation);
        animImg.startAnimation(translate);
        break;
}
    }
}